package io.virtualapp.home.models;

import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;

import org.litepal.crud.DataSupport;

/**
 * @author Lody
 */

public class AppInfo extends DataSupport implements Parcelable {
    public String packageName;
    public String path;
    public boolean fastOpen;
    public Drawable icon;
    public CharSequence name;
    public int cloneCount;
    public int current;//当前位置
    public boolean _issystem;        //是否是系统应用
    public AppInfo(){

    }

    protected AppInfo(Parcel in) {
        packageName = in.readString();
        path = in.readString();
        fastOpen = in.readByte() != 0;
        cloneCount = in.readInt();
        current = in.readInt();
        _issystem = in.readByte() != 0;
    }

    public static final Creator<AppInfo> CREATOR = new Creator<AppInfo>() {
        @Override
        public AppInfo createFromParcel(Parcel in) {
            return new AppInfo(in);
        }

        @Override
        public AppInfo[] newArray(int size) {
            return new AppInfo[size];
        }
    };

    public String getPackageName() {
        return packageName;
    }

    public void setPackageName(String packageName) {
        this.packageName = packageName;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public boolean isFastOpen() {
        return fastOpen;
    }

    public void setFastOpen(boolean fastOpen) {
        this.fastOpen = fastOpen;
    }

    public Drawable getIcon() {
        return icon;
    }

    public void setIcon(Drawable icon) {
        this.icon = icon;
    }

    public CharSequence getName() {
        return name;
    }

    public void setName(CharSequence name) {
        this.name = name;
    }

    public int getCloneCount() {
        return cloneCount;
    }

    public void setCloneCount(int cloneCount) {
        this.cloneCount = cloneCount;
    }

    public int getCurrent() {
        return current;
    }

    public void setCurrent(int current) {
        this.current = current;
    }

    public boolean is_issystem() {
        return _issystem;
    }

    public void set_issystem(boolean _issystem) {
        this._issystem = _issystem;
    }

    public AppInfo(String packageName, String path, boolean fastOpen, Drawable icon, CharSequence name, int cloneCount, int current, boolean _issystem) {
        this.packageName = packageName;
        this.path = path;
        this.fastOpen = fastOpen;
        this.icon = icon;
        this.name = name;
        this.cloneCount = cloneCount;
        this.current = current;
        this._issystem = _issystem;
    }

    @Override
    public String toString() {
        return "AppInfo{" + "packageName='" + packageName + '\'' + ", path='" + path + '\'' + ", fastOpen=" + fastOpen + ", icon=" + icon + ", name=" + name + ", cloneCount=" + cloneCount + ", current=" + current + ", _issystem=" + _issystem + '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(packageName);
        dest.writeString(path);
        dest.writeByte((byte) (fastOpen ? 1 : 0));
        dest.writeInt(cloneCount);
        dest.writeInt(current);
        dest.writeByte((byte) (_issystem ? 1 : 0));
    }
}
